﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Microsoft.Reporting.WebForms;
using System.Data.SqlClient;

namespace web
{
    public partial class report : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void showReport_Click(object sender, EventArgs e)
        {
            string vRoleID = this.txtRoleID.Text.Trim().ToString();
            string str = "where user_roleid='" + vRoleID + "'";
            if (vRoleID == "")
            {
                str = "where 1=1";
            }
            SqlConnection myConn = new SqlConnection("Data Source=.;Initial Catalog=access;Persist Security Info=True;User ID=sa;Password=123456");
            SqlDataAdapter myda = new SqlDataAdapter("select * from tab_user " + str, myConn);
            DataSet myds = new DataSet();
            myConn.Open();
            myda.Fill(myds);
            myConn.Close();

            ReportViewer1.Visible = true;


            ReportDataSource rds = new ReportDataSource("accessDataSet_tab_user", myds.Tables[0]);
            ReportViewer1.LocalReport.DataSources.Clear();
            ReportViewer1.LocalReport.DataSources.Add(rds);
            ReportViewer1.LocalReport.Refresh();
        }
    }
}
